/* eslint-disable @typescript-eslint/no-explicit-any */
import { Fragment, jsxs } from './jsx-runtime';
import { ObjectProps, JSXClass, BaseElement, JSXFunction, ChildType } from './types';

export function h<T extends HTMLElement>(
	tag: JSXFunction | JSXClass<any> | (new () => T) | string,
	props: ObjectProps<any> | null,
	...children: ChildType[]
): BaseElement | DocumentFragment {
	return jsxs(tag, { ...props, children });
}

export function fragment(props: ObjectProps<any> | null, children: ChildType[]): DocumentFragment {
	return jsxs(Fragment, props ? props : { children });
}
